<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app"></div>
    <template id="t1">
      <div>
        <!-- <button @click="user.email='jack@qq.com'">
          user.email='jack@qq.com'
        </button> -->
        <!-- <button @click="delete user.age">delete user.age</button> -->

        <!-- $set(对象变量,属性名,值) 新增对象属性，保持响应式 -->
        <button @click="$set(user,'email','jack@qq.com')">
          $set(user,'email','jack@qq.com')
        </button>
        <!-- $delete(对象变量,属性名) 删除对象属性，保持响应式 -->
        <button @click="$delete(user,'age')">$delete(user,'age')</button>

        <!-- 对对象属性值的修改默认都是响应式 -->
        <button @click="user.age=100">user.age=100</button>
        <ul>
          <li v-for="v in user" :key="v">{{v}}</li>
        </ul>
      </div>
    </template>
    <script src="./vue.js"></script>
    <script>
      const vm = new Vue({
        el: "#app",
        template: "#t1",
        data: {
          user: {
            name: "jack",
            age: 20,
            gender: "boy",
          },
        },
      });
    </script>
  </body>
</html>
